import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @Author: Lenovo
 * @Date: 2024/6/2 14:03
 * @description:
 */
class Person implements Cloneable{

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class Test{
    public static int getData(){
        Scanner sc = null;
        try{
            sc = new Scanner(System.in);
            int data = sc.nextInt();
            return data;
        }catch (InputMismatchException e){
            e.printStackTrace();
        }finally {
            sc.close();
            System.out.println("finally中代码");
        }
        System.out.println("try-catch-finally之后代码");
        return 0;
    }
    public static void main(String[] args) {
        int data = getData();
        System.out.println(data);
    }

    public static void main7(String[] args) {
        int[]arr={1,2,3,4};
        try {
            System.out.println(arr[5]);
            arr=null;
            System.out.println(arr.length);
        }catch (NullPointerException e){
            System.out.println("空指针异常");
            e.printStackTrace();
        }catch (Exception e){
            System.out.println("数组越界");
            e.printStackTrace();
        }
        System.out.println("after");
    }
    /*public static void main7(String[] args) {
        int[]arr={1,2,3,4};
        try {
            System.out.println(arr[5]);
            arr=null;
            System.out.println(arr.length);
        }catch (Exception e){
            System.out.println("数组越界");
            e.printStackTrace();
        }catch (NullPointerException e){
            System.out.println("空指针异常");
            e.printStackTrace();
        }
        System.out.println("after");
    }*/
    public static void main6(String[] args) {
        int[]arr={1,2,3,4};
        try {
            System.out.println(arr[5]);
            arr=null;
            System.out.println(arr.length);
        }catch (ArrayIndexOutOfBoundsException|NullPointerException  e){
            System.out.println("数组越界");
            e.printStackTrace();
        }
        System.out.println("after");
    }
    public static void main5(String[] args) {
        int[]arr={1,2,3,4};
        try {
            System.out.println(arr[5]);
            arr=null;
            System.out.println(arr.length);
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("数组越界");
            e.printStackTrace();
        }catch (NullPointerException e){
            System.out.println("空指针异常");
            e.printStackTrace();
        }
        System.out.println("after");
    }
    public static void func(int a) throws ArithmeticException{
        if(a==0){
            throw new ArithmeticException();
        }
    }

    public static void main4(String[] args) {
        try {
            func(0);
            System.out.println("haha");
        }catch (ArithmeticException e){
            System.out.println("捕获了异常，处理异常....");
            e.printStackTrace();
        }
        System.out.println("处理成功...");
    }

    public static void func1(int x){
        if(x==0){
            throw  new ArithmeticException("分母不能为0");
            //System.out.println("haha");
        }
    }

    public static void main3(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个分母:");
        int a=sc.nextInt();
        //func(a);
    }
    public static void main2(String[] args)throws CloneNotSupportedException {
        Person person=new Person();
        person.clone();
    }
    public static void main1(String[] args) {
        //System.out.println(10/0);
       /* int[]arr={1,2,3,4,5};
        System.out.println(arr[5]);*/
        int[]arr=null;
        System.out.println(arr.length);
    }
}
